package com.group01.community.controller;


import com.group01.community.entity.SysMenu;
import com.group01.community.entity.SysRoleMenu;
import com.group01.community.service.SysRoleMenuService;
import com.group01.community.utils.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 角色和菜单关联表 前端控制器
 * </p>
 *
 * @author guoyuan
 * @since 2025-05-01
 */
@RestController
@RequestMapping("/sysRoleMenu")
public class SysRoleMenuController {

    @Autowired
    private SysRoleMenuService sysRoleMenuService;

    @ApiOperation("根据roldid查询菜单ids")
    @GetMapping("/getMenuIdsByRoldId")
    public ResponseResult<List<SysRoleMenu>> getMenuIdsByRoldId(String roleId){
        List<SysRoleMenu> menuIdsByRoldId = sysRoleMenuService.getMenuIdsByRoldId(roleId);
        return ResponseResult.ok(menuIdsByRoldId);
    }


    @GetMapping("/getCurrentUserMenu")
    @ApiOperation("获取当前用户菜单")
    public ResponseResult <List<SysMenu>> getCurrentUserMenu(){
        List<SysMenu> menuIdsByRoldId = sysRoleMenuService.getCurrentUserMenu();
        return ResponseResult.ok(menuIdsByRoldId);
    }
}

